<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>斐波纳契奇数求和算法</title>
	</head>
	<body>
		<script>
		function sumFibs(num) {
			if(num<1){
				return "输入有误！"
			}else if(num==1){
				return 2;
			}else{
				var arr=[1,1]
				for(var i=0;i<=num;){
					i=arr[arr.length-1]+arr[arr.length-2];
					if(i>num){
						break;
					}
					arr.push(i);
				}
				var s=0;
				for(var i=0;i<arr.length;i++){
					var k=arr[i]/2;
					if(k!=Math.floor(k))
					s=s+arr[i];
				}
				return s;
			}
		    //return num;
		}
		
		document.write(sumFibs(4));	
		</script>
	</body>
</html>
